//
//  TTToolbarSaver.m
//  Tint
//
//  Created by Kevin Wu on 3/6/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import "TTToolbarSaver.h"

@implementation TTToolbarSaver

TTSynthesizeSingleton(TTToolbarSaver);


#pragma mark - Public

- (void)pushToolbar:(UIToolbar *)toolbar {
    TTToolbarSaverItem *item = [TTToolbarSaverItem make];
    item.tintColor = toolbar.tintColor;
    item.transluceent = toolbar.translucent;
    item.barStyle = toolbar.barStyle;
    [_appearances push:item];
}

- (void)popToolbar:(UIToolbar *)toolbar {
    TTToolbarSaverItem *item = [_appearances pop];
    if (item) {
        [toolbar setTintColor:item.tintColor];
        [toolbar setTranslucent:item.transluceent];
        [toolbar setBarStyle:item.barStyle];
    }
}

@end



@implementation TTToolbarSaverItem
@synthesize tintColor = _tintColor;
@synthesize transluceent = _transluceent;
@synthesize barStyle = _barStyle;
- (void)dealloc {
    TTRelease(_tintColor);
    [super dealloc];
}
@end
